/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package cpasl;

import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.geometry.Pos;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.control.RadioButton;
import javafx.scene.control.TextField;
import javafx.scene.control.ToggleGroup;
import javafx.scene.layout.GridPane;

/**
 *
 * @author seanm_000
 */
public class EthnicGridPane extends GridPane {
    
    public EthnicGridPane() {
        setAlignment(Pos.CENTER);
        setHgap(15);
        setVgap(15);
        
        Label ethnicityLabel = new Label("What is your ethnic background?");
        final ToggleGroup ethnicityGroup = new ToggleGroup();
        RadioButton hispanicButton = new RadioButton("Hispanic");
        hispanicButton.setId("questionnaire-button");
        hispanicButton.setUserData("A");
        hispanicButton.setToggleGroup(ethnicityGroup);
        hispanicButton.setSelected(true);
        RadioButton nonHispanicButton = new RadioButton("Non-Hispanic");
        nonHispanicButton.setId("questionnaire-button");
        nonHispanicButton.setUserData("B");
        nonHispanicButton.setToggleGroup(ethnicityGroup);
        RadioButton naButton = new RadioButton("Prefer not to respond");
        naButton.setId("questionnaire-button");
        naButton.setUserData("C");
        naButton.setToggleGroup(ethnicityGroup);
        
        Button nextButton = new Button();
        nextButton.setText("Next");
        nextButton.setId("next-button");
        nextButton.setOnAction(new EventHandler<ActionEvent>() {

            @Override
            public void handle(ActionEvent event) {
                String userData = (String) ((RadioButton) ethnicityGroup.getSelectedToggle()).getUserData();
                CpaslManager.getInstance().setEthnicBackground(userData);
                CpaslManager.getInstance().switchToDisplay(Groups.RACE, 0);
            }
        });
        
        add(ethnicityLabel, 0, 0);
        add(hispanicButton, 0, 1);
        add(nonHispanicButton, 0, 2);
        add(naButton, 0, 3);
        add(nextButton, 0, 4);
    }
    
}
